package com.sskj.gocoin.p.fragment;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.gocoin.m.HttpConfig;
import com.sskj.gocoin.m.bean.HttpData;
import com.sskj.gocoin.m.bean.NoticeEntry;
import com.sskj.gocoin.m.http.JsonCallBack;
import com.sskj.gocoin.p.base.BasePresenter;
import com.sskj.gocoin.utils.ToastUtil;
import com.sskj.gocoin.v.activity.InforMationActivity;

/**
 * Created by Administrator on 2018/4/16.
 */

public class NoticePresenter extends BasePresenter<InforMationActivity> {

    public void getData(int pageNum) {
        OkGo.<HttpData<NoticeEntry>>get(HttpConfig.BASE_URL + HttpConfig.NOTICE)
                .params("p", pageNum)
                .execute(new JsonCallBack<HttpData<NoticeEntry>>(this) {
                    @Override
                    public void _onSuccess(Response<HttpData<NoticeEntry>> response) {
                        if (response != null) {
                            if (response.body().getStatus() == 200) {
                                mView.setData(response.body().getData());
                            } else {
                                ToastUtil.showShort(response.body().getMsg());
                            }
                        }

                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }
}
